package com.myworkbench.workbench.domain.valueobject;

import com.myworkbench.workbench.domain.ValueObject;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import java.time.LocalDateTime;

/**
 *  更新者
 */
@Data
@Embeddable
@AllArgsConstructor
@NoArgsConstructor
public final class Updator extends ValueObject<Updator> {
  @NonNull
  @Column(length = 11,nullable = false)
  private Integer updateUserId;
  @Column(length = 50)
  private String updateRealName;
  private LocalDateTime updateTime;
  /**
   * @desc 覆盖equals方法
   */
  @Override
  public boolean equals(Object obj){
    if(obj == null){
      return false;
    }
    //如果是同一个对象返回true，反之返回false
    if(this == obj){
      return true;
    }
    //判断是否类型相同
    if(this.getClass() != obj.getClass()){
      return false;
    }
    Updator updator = (Updator)obj;
    return this.updateUserId == updator.updateUserId;
  }

  @Override
  public boolean sameValueAs(Updator other) {
    return false;
  }
}
